package com.itheima.exerciseTest.method20_29.method21;

import java.io.*;

public class Test {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        User u = new User();
        u.setUsername("123456");
        u.setPassword("987654");
        u.setAge(111);

        // 创建对象序列化流
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("backBurner\\j.txt"));
        oos.writeObject(u);
        oos.close();

        // 创建对象反序列化流
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("backBurner\\j.txt"));
        Object o = ois.readObject();
        ois.close();
        System.out.println(o);
    }
}
